//package com.tiger.cloud.controller.test;
//
//import com.tiger.cloud.enums.*;
//import com.tiger.cloud.filter.IgnoreAuth;
//import com.tiger.cloud.form.CompanyForm;
//import com.tiger.cloud.form.UserLoginForm;
//import com.tiger.cloud.model.crm.*;
//import com.tiger.cloud.service.crm.*;
//import com.tiger.cloud.util.DateTimeUtil;
//import io.swagger.annotations.Api;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import java.math.BigDecimal;
//import java.util.Date;
//import java.util.Random;
//
//@Controller
//@RequestMapping(value = "insert")
//@Api(value = "添加数据", tags = "添加数据")
//public class InsertDataTestController {
//
//	@Autowired
//	private IUserCompanyInfoService userCompanyInfoService;
//	@Autowired
//	private ICustomerService customerService;
//	@Autowired
//	private IUserService userService;
//	@Autowired
//	private ILoanRecordService loanRecordService;
//	@Autowired
//	private IRecommandListService recommandListService;
//	@Autowired
//	private ICommucationService commucationService;
//	@Autowired
//	private ILoanInfoService loanInfoService;
//	@Autowired
//	private ILoanInfoDetailService loanInfoDetailService;
//
//	private static Long getNextUserId(Long minUserId, Long maxUserId) {
//		int max = maxUserId.intValue();
//		int min = minUserId.intValue();
//		return new Random().nextInt(max) % (max - min + 1) + min + 0l;
//	}
//
//	private static String[] images = { "http://img2.woyaogexing.com/2017/09/28/7f7036fc15b97d65!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/dc88f96d59c371c0!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/94ad6ee8ea7fa3fd!400x400_big.jpg", "http://img2.woyaogexing.com/2017/09/28/0d8ddd2faba6d07c!200x200.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/493685f8009c2d77!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/7d9e99e6fd1a27ee!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/77ad89b265fbdcdf!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/91668eeecfaa49ca!400x400_big.png",
//			"http://img2.woyaogexing.com/2017/09/27/dad36e4fd3ffa0b9!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/493685f8009c2d77!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/7d9e99e6fd1a27ee!400x400_big.jpg", "http://img2.woyaogexing.com/2017/09/28/0d8ddd2faba6d07c!200x200.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/77ad89b265fbdcdf!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/91668eeecfaa49ca!400x400_big.png",
//			"http://img2.woyaogexing.com/2017/09/27/dad36e4fd3ffa0b9!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/8b550eb74bcdde24!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/e6acfa7b5c340875!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/12362d1cc121df0e!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/ed45d51a91104e74!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/26/8a5203eebf5f6596!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/26/921a0491d9b8bda2!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/26/39f14a36743e2f0a!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/26/6ceb6e7d9526a753!400x400_big.jpg", "http://img2.woyaogexing.com/2017/09/26/84791269a64172e8!200x200.jpg",
//			"http://img2.woyaogexing.com/2017/09/25/756de475d82d1164!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/25/70f7e15d0686e7b4!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/25/62baa77fc7cd50f3!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/25/601c847dbcc2efe9!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/25/b34972e00f52d585!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/25/4d1fdac2a5f91291!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/75a5d05ed2ccf11f!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/4b8e3de4262c1bda!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/6fa354e14eed3e1e!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/62f14d1b65c0c7b0!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/568ca2893cf102c1!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/7b44e57dc9d3015f!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/a5cd23194788736e!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/99aacffc6a9a5fcd!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/bc858d0f36d4fce0!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/5b7527ec2e794377!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/ffdd8722ba9aa6d7!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/9d95394f0d57c6cc!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/5bfafab3eef438323463997c2f067330.jpg",
//			"http://img2.woyaogexing.com/2017/09/23/d18ffe433c4a7961!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/23/27ceb91ab98234a2!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/e5994f0c114cf05e!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/493685f8009c2d77!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/27/dad36e4fd3ffa0b9!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/24/568ca2893cf102c1!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/28/5bfafab3eef438323463997c2f067330.jpg",
//			"http://img2.woyaogexing.com/2017/09/23/584864db7ae4cc97!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/23/45f72aa7db82be26!400x400_big.jpg", "http://img2.woyaogexing.com/2017/09/18/d06e11ed54e60195!200x200.jpg",
//			"http://img2.woyaogexing.com/2017/09/17/4c50582bc8d2b0ec!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/17/e800d35d8c33d1b1!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/15/b598a5da36bfe9be!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/14/4d018c68179a2681!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/14/63ec79185b5f2fab!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/14/02f34f6b162f2d92!400x400_big.jpg",
//			"http://img2.woyaogexing.com/2017/09/14/91bf2bddded3c053!400x400_big.jpg" };
//
//	private static String[] images2 = { "http://www.qqtouxiang.com/d/file/dongwu/2017-05-10/28f8ae77e37d76f19260693058973d73.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-05-10/e3709603f8b6435db2c101a28546d64c.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-05-10/9951a0db4ccd14090c75d8291d7aa41e.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-05-10/c93a4a5fa589e87490651954d31424ee.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-05-10/47b73ff3fa24edefc641394bf2e4e3f6.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-05-09/d1b0557da6153897b567320bd1e52eb0.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-04-25/75d85232938c210e62f1dabc9e0b39a7.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2017-04-20/68c5e7736d1e20fc692aa101e6672206.jpg", "http://q.qqtouxiang.com/q/2014/06/3017433264915.jpg",
//			"http://www.qqtouxiang.com/d/file/dongwu/2016-12-30/830bf4b35629c773f11fd2dfdde5a423.jpg" };
//
//	private static String getImage() {
//		int count = new Random().nextInt(images.length);
//		return images[count];
//	}
//
//	private static String getImage2() {
//		int count = new Random().nextInt(images2.length);
//		return images2[count];
//	}
//
//	private static Long logId = 1850000000L;
//	private static Long mixUserId = 1000l;
//	private static Long maxUserId = 10000l;
//	private static Long count = 10000l;
//
//	@RequestMapping(value = "insertUData")
//	@ResponseBody
//	@IgnoreAuth
//	public void insertUData() {
//		for (int i = 1; i < 100; i++) {
//			logId = logId + 1;
//			String username = ChineseName.getUserName();
//
//			UserLoginForm userLoginForm = new UserLoginForm();
//			userLoginForm.setLoginId(String.valueOf(logId));
//
//			userLoginForm.setPassword("123456");
//			userLoginForm.setJpushCode(String.valueOf(logId));
//
//			User user = userService.register(userLoginForm);
//			if (i == 0) {
//				mixUserId = user.getId();
//				maxUserId = mixUserId + count;
//			}
//
//			CompanyForm company = new CompanyForm();
//			company.setBusinessCard(getImage() + "|" + getImage());
//			company.setUsername(username);
//			company.setUserId(user.getId());
//			company.setHeadImage(getImage());
//			company.setUsername(String.valueOf(logId));
//			company.setCompanyName(username + "科技");
//			company.setProvinceId(320000L);
//			company.setProvinceName("江苏省");
//			company.setCityId(320100L);
//			company.setCityName("南京市");
//			company.setDistrictId(320111L);
//			company.setDistrictName("浦口区");
//			userCompanyInfoService.register(company);
//		}
//	}
//
//	@RequestMapping(value = "insertUData2")
//	@ResponseBody
//	@IgnoreAuth
//	public void insertUData2() {
//
//
//			new Thread(new Runnable() {
//
//				@Override
//				public void run() {
//					for (int i = 0; i <1; i++) {
//						logId = logId + i;
//						User user = userService.get(18L);
//						String username = ChineseName.getUserName();
//
//						if(user==null){
//							continue;
//						}
//
//						for (int j = 1; j < 150; j++) {
//							String name = "客户" + i + "--" + j;
//							Customer customer = new Customer();
//							customer.setHeadImage(getImage2());
//							customer.setIsDelete(DeleteEnum.NOMAIL);
//							customer.setUserId(user.getId());
//							customer.setCustName(name);
//							customer.setBorn(DateTimeUtil.addDays(new Date(), -(i * j * 183)));
//							customer.setAddressProvinceId(320000L);
//							customer.setAddressProvinceName("江苏省");
//							customer.setAddressCityId(320400L);
//							customer.setAddressCityName("常州市");
//							customer.setAddressDistrictId(320411L);
//							customer.setAddressDistrictName("新北区");
//							customer.setBorn(DateTimeUtil.getSystemDate());
//							customer.setCreditStatus(CreditStatusEnum.GENERAL);
//							customer.setIdentity(IdentityEnum.BOSS);
//							customer.setOrigoProvinceId(320000L);
//							customer.setOrigoProvinceName("江苏省");
//							customer.setOrigoCityId(320100L);
//							customer.setOrigoCityName("南京市");
//							customer.setOrigoDistrictId(320111L);
//							customer.setOrigoDistrictName("浦口区");
//							customer.setRemark(username + "添加数据");
//							customer.setUserWork("老板");
//							customer.setWeixin(logId + "");
//
//							customerService.insert(customer);
//
//							LoanInfo loanInfo = new LoanInfo();
//							loanInfo.setUserId(user.getId());
//							loanInfo.setCustomerId(customer.getId());
//							loanInfo.setAmount(new BigDecimal((i * j * 43) / 2.389));
//							loanInfo.setLoanPeriod("10");
//							loanInfo.setLoanTypeId(6L);
//							loanInfo.setLoanType(LoanRecordType.OTHER_PROPERTY);
//							loanInfo.setIsDelete(DeleteEnum.NOMAIL);
//							loanInfo.setMemo("10.1祭天吗?");
//							loanInfo.setAttachment(getImage2());
//							loanInfo.setLoanIntent("1");
//
//							loanInfoService.insert(loanInfo);
//
//							LoanInfoDetail loanInfoDetail = new LoanInfoDetail();
//							loanInfoDetail.setLoanInfoId(loanInfo.getId());
//							loanInfoDetail.setLoanTypeId(6L);
//							loanInfoDetail.setLoanType(LoanRecordType.OTHER_PROPERTY);
//							loanInfoDetail.setKeyDictId(1L);
//							loanInfoDetail.setKeyName("other_bug_price");
//							loanInfoDetail.setValue("6666");
//							loanInfoDetail.setMemo(username + "抵押借钱");
//
//							loanInfoDetailService.insert(loanInfoDetail);
//
//							if (j % 2 == 0) {
//								LoanRecord loanRecord = new LoanRecord();
//								loanRecord.setUserId(user.getId());
//								loanRecord.setIsDelete(DeleteEnum.NOMAIL);
//								loanRecord.setAmount(new BigDecimal((i * j * 33) / 2.389));
//								loanRecord.setCustomerId(customer.getId());
//								loanRecord.setCustomerName(name);
//								loanRecord.setStartDate(DateTimeUtil.addDays(DateTimeUtil.getSystemDate(), -(i * 56)));
//								loanRecord.setBizType(LoanRecordBizType.OWER_DEVELOPMENT);
//								loanRecord.setLoanPeriod("10");
//								loanRecord.setStatus(LoanRecordStatus.NORMAL);
//								loanRecord.setType(LoanRecordRowType.LOAN);
//								loanRecord.setHowEnd(LoanRecordHowEnd.IMMOVABLE_PROPERTY);
//								loanRecord.setLoanType(LoanRecordType.IMMOVABLE_PROPERTY);
//								loanRecord.setLoanTypeValue("不动产抵押");
//								loanRecordService.insert(loanRecord);
//							}
//						}
//						if(i%3==0){
//							try {
//								Thread.sleep(300);
//							} catch (InterruptedException e) {
//								e.printStackTrace();
//							}
//						}
//					}
//				}
//			}).start();
//
//	}
//
//	@RequestMapping(value = "insertUData3")
//	@ResponseBody
//	@IgnoreAuth
//	public void insertUData3() {
//			new Thread(new Runnable() {
//
//				@Override
//				public void run() {
//					for (int i = 0; i <1; i++) {
//						logId = logId + i;
//						User user = userService.get(18L);
//						String username = ChineseName.getUserName();
//
//						if(user==null){
//							continue;
//						}
//						Long nextUserId = 26l;
//						for (int k = 1; k < 101; k++) {
//
//							if (user.getId().longValue() == nextUserId.longValue()) {
//								continue;
//							}
//							RecommandList recommandList = new RecommandList();
//							recommandList.setUserId(user.getId());
//							recommandList.setRecommandDate(DateTimeUtil.getSystemDate());
//							recommandList.setIsDelete(DeleteEnum.NOMAIL);
//							recommandList.setAcceptIsDelete(DeleteEnum.NOMAIL);
//							recommandList.setAcceptStatus(RecommandListAcceptStatus.WAIT_ACCEPT);
//							recommandList.setRecommandId(nextUserId);
//							recommandList.setUserName(username + "朋友");
//							recommandList.setUserMobile(String.valueOf(logId));
//							recommandList.setType(i % 2 == 0 ? 1 : 2);
//							recommandList.setRecommandWay(i % 2 == 0 ?ResourceTypeEnum.CRM_MATCH:ResourceTypeEnum.QR_CODE);
//							recommandList.setStatus(RecommandListStatus.CREATED);
//							RecommandList recommand = new RecommandList();
//							recommand.setUserId(recommandList.getUserId());
//							recommand.setRecommandId(recommandList.getRecommandId());
//							recommand = recommandListService.findOne(recommand);
//							if(recommand != null){
//								nextUserId++;
//								continue;
//							}else{
//								recommandListService.insert(recommandList);
//							}
//
//							recommandListService.acceptRequest(recommandList,18l);
//
//							Commucation commucation = new Commucation();
//							if (k % 3 == 0) {
//								commucation.setAttachment(getImage2());
//							}
//							commucation.setCustomerType(CommucationCustomerType.PEERS);
//							commucation.setContent("10.1哪儿hi?"+i);
//							commucation.setCustomerId(nextUserId);
//							commucation.setCommucationDate(DateTimeUtil.addDays(DateTimeUtil.getSystemDate(), -(i * 36)));
//							commucation.setUserId(user.getId());
//							commucation.setIsDelete(DeleteEnum.NOMAIL);
//							commucationService.insertAndUpdateCommunicatTime(commucation);
//							nextUserId++;
//						}
//						if(i%3==0){
//							try {
//								Thread.sleep(300);
//							} catch (InterruptedException e) {
//								e.printStackTrace();
//							}
//						}
//					}
//				}
//			}).start();
//		}
//
//}
